package cn.jinjimi.app.entity;

import cn.jinjimi.base.util.Scheme;
import cn.jinjimi.app.custom.entity.Follow;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * Created by Roy
 * Date: 15/10/27
 * <p/>
 * 本地相册图片bean<br>
 * {@link #imageId}图片id<br>
 * {@link #absolutePath} 绝对路径<br>
 * {@link #filePath} 用于显示的路径<br>
 * {@link #choose} 是否被选择<br>
 */
public class PhotoInfo implements Serializable {
    private static final long serialVersionUID = 1L;
    private long imageId;
    private String filePath;  // 显示的file
    private String absolutePath; // 绝对路径
    private boolean choose = false;
    private int position;

    private long id;
    private String image_url;
    private String thumbnail_url;

    public PhotoInfo() {
    }

    public PhotoInfo(String filePath) {
        this(0, filePath);
    }

    public PhotoInfo(long imageId, String filePath) {
        this.imageId = imageId;

        if (filePath.contains(Scheme.FILE)) {
            this.filePath = filePath;
            this.absolutePath = filePath.substring(Scheme.FILE.length());
        } else {
            this.filePath = Scheme.FILE + filePath;
            this.absolutePath = filePath;
        }
    }

    public static List<PhotoInfo> FollowAttachmentParsePhotoInfo(List<Follow.Attachment> attachments) {
        List<PhotoInfo> list = new ArrayList<>();
        for (Follow.Attachment attachment : attachments) {
            PhotoInfo photoInfo = new PhotoInfo();
            photoInfo.setImage_url(attachment.imageUrl);
            photoInfo.setThumbnail_url(attachment.thumbnailUrl);
            photoInfo.setId(attachment.id);
            list.add(photoInfo);
        }
        return list;
    }

    public long getId() {
        return id;
    }

    public void setId(long id) {
        this.id = id;
    }

    public String getImage_url() {
        return image_url;
    }

    public void setImage_url(String image_url) {
        this.image_url = image_url;
    }

    public String getThumbnail_url() {
        return thumbnail_url;
    }

    public void setThumbnail_url(String thumbnail_url) {
        this.thumbnail_url = thumbnail_url;
    }

    public long getImageId() {
        return imageId;
    }

    public void setImageId(int imageId) {
        this.imageId = imageId;
    }

    public String getPathFile() {
        return filePath;
    }

    public void setPathFile(String path_file) {
        this.filePath = path_file;
    }

    public int getPosition() {
        return position;
    }

    public void setPosition(int position) {
        this.position = position;
    }

    public String getAbsolutePath() {
        return absolutePath;
    }

    public void setAbsolutePath(String path_absolute) {
        this.absolutePath = path_absolute;
    }

    public boolean isChoosed() {
        return choose;
    }

    public void setChoose(boolean choose) {
        this.choose = choose;
    }

}
